package com.pinyoumei.app.adapter;

import android.content.Context;
import android.support.annotation.Nullable;
import android.text.TextUtils;
import android.view.View;
import android.widget.AdapterView;
import android.widget.TextView;

import com.pinyoumei.app.R;
import com.pinyoumei.app.activity.UserManageActivity;
import com.pinyoumei.app.bean.UserManageBean;
import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.pinyoumei.app.dialog.CallPhoneDialog;
import com.pinyoumei.app.utils.ToastUtils;
import com.pinyoumei.app.utils.Utils;
import com.pinyoumei.app.view.dialog.CallDialog;

import java.util.List;

import de.hdodenhof.circleimageview.CircleImageView;

/**
 * Created by Administrator on 2021-08-09.
 * --------- 日期 ------- 维护人 ------------ 变更内容 --------
 * 2021-08-09        Administrator             新增Person类
 * 2021-08-09        Administrator             增加sex属性
 */
public class UserManageAdapter extends BaseQuickAdapter<UserManageBean.ResultBean.UserListBean, BaseViewHolder> {
    private Context context;
    public UserManageAdapter(Context context,int layoutResId, @Nullable List<UserManageBean.ResultBean.UserListBean> data) {
        super(layoutResId, data);
        this.context = context;
    }

    @Override
    protected void convert(BaseViewHolder helper, UserManageBean.ResultBean.UserListBean item) {
        CircleImageView circleImageView = helper.getView(R.id.image_user_icon);
        Glide.with(mContext).load(item.getUser_head_img())
                .into(circleImageView);

        helper.setText(R.id.text_username,item.getUser_real_name());
//        if(TextUtils.equals(item.getLevel_name(),"V4") || TextUtils.equals(item.getLevel_name(),"V5")){
//            helper.setText(R.id.tv_user_level,"V3");
//        }else{
//            helper.setText(R.id.tv_user_level,item.getLevel_name());
//        }
        helper.setImageResource(R.id.iv_user_level, Utils.getLevelIcon(item.getLevel_name()));
        helper.setText(R.id.tv_percent,item.getRegister_time());



        TextView tv_recommand_level = helper.getView(R.id.tv_recommand_level);
        //用户类型 1直接 大于1 团队 示例：1
        if (item.getRecommand_level() == 1){
            tv_recommand_level.setText("直接");
            helper.setVisible(R.id.iv_phone,true);
        }else{
            tv_recommand_level.setText("团队");
            helper.setVisible(R.id.iv_phone,false);
        }

        helper.setText(R.id.tv_direct_custom_day_num,item.getToday_recharge_amount()+"元");
        helper.setText(R.id.tv_team_custom_all_num,item.getTotal_recharge_amount()+"元");

        helper.setText(R.id.tv_direct_custom_num,item.getDirect_custom_num()+"人");
        helper.setText(R.id.tv_team_custom_num,item.getTeam_custom_num()+"人");

        helper.setText(R.id.tv_hp_order_num,item.getGroup_buy_num()+"笔");
        helper.setText(R.id.tv_hp_order_amount,item.getGroup_buy_order_amount()+"元");

        helper.setText(R.id.tv_group_buy_num,item.getHp_order_num()+"笔");
        helper.setText(R.id.tv_group_buy_order_amount,item.getHp_order_amount()+"元");

        helper.setText(R.id.tv_return_profit_order_num,item.getReturn_profit_order_num()+"笔");
        helper.setText(R.id.tv_return_profit_order_amount,item.getReturn_profit_order_amount()+"元");

        helper.setOnClickListener(R.id.iv_phone, new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                CallPhoneDialog callDialog = new CallPhoneDialog(context, new int[]{}, item.getUser_phone());
                callDialog.show();
            }
        });

    }
}
